//
//  ViewController.m
//  Masonry-01
//
//  Created by hyl on 16/5/19.
//  Copyright © 2016年 hyl. All rights reserved.
//

#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self test3];
}
-(void) test1{
    UIView *redView=[[UIView alloc]init];
    redView.backgroundColor=[UIColor redColor];
    [self.view addSubview:redView];
    
    UIView *blueView=[[UIView alloc]init];
    blueView.backgroundColor=[UIColor blueColor];
    [self.view addSubview:blueView];
    
    [redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.mas_equalTo(self.view).offset(20);
        make.right.mas_equalTo(blueView.mas_left).offset(-20);
        make.width.and.height.mas_equalTo(blueView);
        make.height.mas_equalTo(50);
    }];
    [blueView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.view).offset(-20);
        make.top.mas_equalTo(self.view.mas_top).offset(20);
    }];
}

-(void) test2{
    UIView *redView=[[UIView alloc]init];
    redView.backgroundColor=[UIColor redColor];
    [self.view addSubview:redView];
    
    UIView *blueView=[[UIView alloc]init];
    blueView.backgroundColor=[UIColor blueColor];
    [self.view addSubview:blueView];
    
    [redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.mas_equalTo(self.view).offset(20);
        make.right.mas_equalTo(blueView.mas_left).offset(-20);
        make.width.and.height.mas_equalTo(blueView);
        make.top.mas_equalTo(blueView.mas_top);
        make.bottom.mas_equalTo(blueView.mas_bottom);
        make.height.mas_equalTo(50);
    }];
    [blueView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.view).offset(-20);
        //make.top.mas_equalTo(self.view.mas_top).offset(20);//
    }];
}

-(void) test3{
    UIView *redView=[[UIView alloc]init];
    redView.backgroundColor=[UIColor redColor];
    [self.view addSubview:redView];
    
    UIView *blueView=[[UIView alloc]init];
    blueView.backgroundColor=[UIColor blueColor];
    [self.view addSubview:blueView];
    
    [redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view.mas_right).offset(-20);
        make.height.equalTo(@50);
        make.height.equalTo(blueView.mas_height);
    }];
    
    [blueView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(redView.mas_right);
        make.top.equalTo(redView.mas_bottom).offset(30);
        make.left.equalTo(redView.mas_centerX);
    }];
}
@end
